import defaultSettings from '@/settings'

const { showSettings, fixedHeader, sidebarLogo } = defaultSettings

const state = {
  showSettings: showSettings, // 暂无用处
  fixedHeader: fixedHeader, // 头部导航是否固定定位
  sidebarLogo: sidebarLogo // 侧边栏头部是否有logo组件
}

const mutations = {
  // 改变设置的值
  CHANGE_SETTING: (state, { key, value }) => {
    // eslint-disable-next-line no-prototype-builtins
    // 比如外部传递过来的值{key:'siderbarLogo',value:false}
    if (state.hasOwnProperty(key)) { // 判断state对象里是否有sidebarLogo属性
      // 如果有就赋值   不想新增,只想更改
      state[key] = value
    }
  }
}

const actions = {
  changeSetting ({ commit }, data) {
    commit('CHANGE_SETTING', data)
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}

